/*
Name = Rabin William David
WSUID = J965V385
C++ HW1 pgm3p1.cpp

Pseudo Code:

Inputs: Asking the user to enter the Numerator and Denominator of the fraction.

Output: Printing out the reduced fraction and the division of the fraction.

including the iostream library
using namespace std for standard input and output

start of class Fraction
	declaring numerator of type int
	declaring denominator of type int
	
	public type for functions 
	constructor for Fraction which initializes the values to 1
	
	void muttator function to set the Numerator
	void muttaor function to set the Denominator
	int accessor function to get the Numerator
	int accessor function to get the Denominator
	void function to to calculate the reduced fraction
		calling the GCD function
	void function to divide the fraction
		divinding the fraction
	int function for the GCD
		if the denominator is greater than numerator
			return GCD(denominator,numerator)
		else if (denominator == 0)
			return numerator
		else
			return GCD(denominator, numerator%denominator)
close of class Fraction;

start of int main()
	declaring all the values that will be used in main
	declaring variable with members of the Fraction class
	start of for loop to loop 3 times
		asking the user to enter the numerator
		taking in the numerator
		calling the setNumerator function and passing the value entered
		asking the user to enter the denominator
		taking in the denominator
		calling the setDenominator function and passing the value entered
		calling the reducedFraction function to print the reduced function
		callind the divideFraction function to print the division answer
	closing the for loop
		
	returning 0
closing main
*/


#include <iostream>							//library iostream


using namespace std;						//for std in and out

class Fraction								//start of class Fraction

{
	int numerator;							//members of the class
	int denominator;
	
	public:									//public functions and constructors
		Fraction() {
			numerator = 1;
			denominator = 1;	}
		Fraction (int a, int b) {
			numerator = a;
			denominator = b;	}
		void setNumerator (int a) {			//mutator function to set the numerator
			numerator = a;	}
		void setDenominator (int b) {		//mutator function to set the denominator
			denominator =b;	}
		int getNumerator() {				//accessor function to set the numerator
			return ((double)numerator);	}
		int getDenominator() {				//accessor function to set the denominator
			return ((double)denominator);	}
		void reducedFraction()	{			//function for the reduced fraction
			int reduced = GCD(numerator,denominator);
			cout<<"The Ratio is:"<<(numerator/reduced)<<"/"<<(denominator/reduced)<<"\n"; }
		void divideFraction() {				//function to divide the fraction
			double divide;
			if (numerator==0 || denominator ==0) {
					divide = 0;	}	
			else { divide = (double(numerator)/double(denominator));}
			cout<<"The division for the fraction is: "<<divide<<"\n";	}
			
		int GCD(int a, int b) {				//function that calculated the GCD 
			if (b>a)
				return GCD(b,a);
			else if (b == 0)
				return a;
			else
				return GCD(b,a%b);		}
};											//closing the class Fraction

int main() {								//start if main
	int num;								//declaring the variables needed
	int den;
	Fraction division;						//variables of class type Fraction which has all the member variables of the Fraction class
	int x =1;
for (x=1;x<=3;x++) {						//for loop to loop 3 times
	cout<<"\nPlease Enter a Fraction (a/b)";
	cout<<"\nEnter the Numerator(a):";
	cin>>num;
	division.setNumerator(num);				//sending the numerator to the mutator function
	cout<<"\nEnter the Denominator(b):";
	cin>>den;
	division.setDenominator(den);			//sending the denominator to the mutator function
	division.reducedFraction();				//printing the reduced fraction
	division.divideFraction();				//printing the division of the fraction
}											//close of for loop
	return 0;	
	
}											//end of main

//creating a conflict2
